home *** CD-ROM | disk | FTP | other *** search
- .Na "dbretdata"
- .mc |
- .Aa
- .Fu
- Return a pointer to a return parameter value generated by a stored procedure.
- .Ih "stored procedure, return parameters"
- .Ih "return parameters from stored procedures"
- .Sy
- .Sf "BYTE *dbretdata(dbproc, retnum)"
- .Sp "DBPROCESS" "*dbproc"
- .Sp "int" "retnum"
- .Co
- .Bl
- \f2dbretdata()\f1 returns a pointer to a return parameter value generated by a stored procedure.
- It is useful in conjunction with remote procedure calls and EXECUTE statements on stored procedures.
- .Bl
- \*N stored procedures can return values for specified ``return parameters.''
- Changes made to the value of a return parameter inside the stored procedure
- are then available to the program that called the procedure.
- This is analogous to the ``pass by reference'' facility available in some
- programming languages.
- .sp 0.5v
- For a parameter to function as a return parameter,
- it must be declared as such within the stored procedure.
- The EXECUTE statement or remote procedure call
- that calls the stored procedure must also indicate that the parameter should function
- as a return parameter.
- In the case of a remote procedure call, it is the \f2dbrpcparam()\f1 routine that specifies whether
- a parameter is a return parameter.
- .Bl
- When executing a stored procedure,
- the server returns any parameter values immediately after returning all other results.
- Therefore, the application can call \f2dbretdata()\f1 only after
- processing the stored procedure's results by calling
- \f2dbresults()\f1, as well as \f2dbnextrow()\f1 if appropriate.
- (Note that a stored procedure can generate several sets of results\(emone for each SELECT
- it contains.
- Before the application can call \f2dbretdata()\f1 or any other routines that
- process return parameters, it
- must call \f2dbresults()\f1 and \f2dbnextrow()\f1 as many times as necessary
- to process all the results.)
- .Bl
- If the stored procedure is invoked with a remote procedure call,
- the return parameter values are automatically available to the application.
- If, on the other hand,
- the stored procedure is invoked with an EXECUTE statement,
- the return parameter values are available only if the command batch
- containing the EXECUTE statement uses
- local variables, not constants, for the return parameters.
- .Bl
- Other routines return additional information about return parameter values:
- .in +3n
- .Bl *
- \f2dbnumrets()\f1 returns the total number of return parameter values.
- .Bl *
- \f2dbretlen()\f1 returns the length of a parameter value.
- .Bl *
- \f2dbretname()\f1 returns the name of a parameter value.
- .Bl *
- \f2dbrettype()\f1 returns the datatype of a parameter value.
- .in -3n
- .Bl
- For an example of this routine,
- see Example 8 in the \f2\*L Reference Supplement\f1.
- .Bz
- .Pa
- .Pi dbproc
- A pointer to the DBPROCESS structure that provides the connection
- for a particular front-end/\*S process. It contains all the
- information that \*L uses to manage communications and data between the
- front end and \*S.
- .Pi retnum
- The number of the return parameter value of interest.
- The first return value is 1.
- Values are returned in the same order as the parameters were originally specified in the stored procedure's
- CREATE PROCEDURE statement.
- (Note that this is not necessarily the same order as specified in the remote procedure call.)
- When specifying \f2retnum\f1, non-return parameters do not count.
- For example, if the second parameter in a stored procedure is the only return parameter, its \f2retnum\f1 is
- 1, not 2.
- .in -.375i
- .Re
- .br
- A pointer to the specified return value.
- If \f2retnum\f1 is out of range, \f2dbretdata()\f1 returns NULL.
- To determine whether the data really has a null value
- (and \f2retnum\f1 is not merely out of range),
- check for a return of 0 from \f2dbretlen()\f1.
- .Sa
- dbnextrow,
- dbnumrets,
- dbresults,
- dbretlen,
- dbretname,
- dbrettype,
- dbrpcinit,
- dbrpcparam
- .mc
-